﻿
using Maticsoft.BLL;
using Maticsoft.DBUtility;

using System;
using System.Data;
using System.Text;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Wuqi.Webdiyer;

public partial class WebPage_Type_XiangmuFenlei : SystemBBasePage
{

    private Category cate = new Category();

    private string sql = "";
    private int text = Convert.ToInt32(PageIndex.pageIndex);


    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        this.getTypeFenlei();
    }

    private void getTypeFenlei()
    {
        int num2;
        StringBuilder builder = new StringBuilder();
        builder.Append("<tr >");
        builder.Append("<th width='50'>ID</th>");
        builder.Append("<th width='250'>中文名称</th>");
        builder.Append("<th width='250'>英文名称</th>");
        builder.Append("<th width='60'>首字母</th>");
        builder.Append("<th width='150'>自定义分组</th>");
        builder.Append("<th width='40' nowrap>导航</th>");
        builder.Append("<th width='40' nowrap>排序</th>");
        builder.Append("<th width='100'>操作</th>");
        builder.Append("</tr>");
        StringBuilder builder2 = new StringBuilder();
        int num = 0;
        this.AspNetPager1.PageSize = this.text;
        DataSet set = DbHelperSQL.Page(this.text, this.AspNetPager1.CurrentPageIndex, "Category", this.sql, "Sort_order desc, Id desc", "*", out num2);
        this.AspNetPager1.RecordCount = num2;
        if ((set.Tables.Count > 0) && (set.Tables[0].Rows.Count > 0))
        {
            for (int i = 0; i < set.Tables[0].Rows.Count; i++)
            {
                DataRow row = set.Tables[0].Rows[i];
                if ((num % 2) != 0)
                {
                    builder2.Append("<tr>");
                }
                else
                {
                    builder2.Append("<tr class='alt'>");
                }
                num++;
                builder2.Append("<td>" + row["Id"] + "</td>");
                builder2.Append("<td>" + row["Name"] + "</td>");
                builder2.Append("<td>" + row["Ename"] + "</td>");
                builder2.Append("<td>" + row["Letter"] + "</td>");
                builder2.Append("<td>" + row["Czone"] + "</td>");
                if (row["Display"].ToString().ToUpper() == "Y")
                {
                    builder2.Append("<td>显示</td>");
                }
                else
                {
                    builder2.Append("<td>隐藏</td>");
                }
                builder2.Append("<td>" + row["Sort_order"] + "</td>");
                builder2.Append("<td class='op'>");
                builder2.Append(string.Concat(new object[] { "<a class='ajaxlink' href='/ajax/manage.aspx?action=categoryedit&zone=", row["Zone"], "&update=", row["Id"], "'>编辑</a>｜" }));
                builder2.Append(string.Concat(new object[] { "<a class=\"remove-record\" href='Type_XiangmuFenlei.aspx?remove=", row["Id"], "&pageIndex=", this.AspNetPager1.CurrentPageIndex, "&where=", DESEncrypt.Encrypt(this.sql, "type"), "'>删除</a>" }));
                builder2.Append("</td>");
                builder2.Append("</tr>");
            }
        }
        this.Literal1.Text = builder.ToString();
        this.Literal2.Text = builder2.ToString();
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.sql = " 1=1 and zone='group' ";
        this.HeaderControl1.Select = "leibie";
        if (!base.IsPostBack)
        {
            if (base.Request.QueryString["remove"] != null)
            {
                this.cate.Delete(Convert.ToInt32(base.Request.QueryString["remove"].ToString()));
                base.SetSuccess("删除成功");
                if ((base.Request.QueryString["pageIndex"] != null) && (base.Request.QueryString["pageIndex"].ToString() != ""))
                {
                    this.AspNetPager1.CurrentPageIndex = Convert.ToInt32(base.Request.QueryString["pageIndex"].ToString());
                }
                if ((base.Request.QueryString["where"] != null) && (base.Request.QueryString["where"].ToString() != ""))
                {
                    this.sql = DESEncrypt.Decrypt(base.Request.QueryString["where"].ToString(), "type");
                }
            }
            this.getTypeFenlei();
        }
    }
}

